<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>消息中心</el-breadcrumb-item>
      <el-breadcrumb-item>我的评论</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row style="margin-top:10px">
      <el-col :span="12" style="padding:50px">
        <h2 style="font-size:30px;font-weight:600;margin-bottom: 20px;">我的观影类型:</h2>
        <Bing />
      </el-col>
      <el-col :span="12" style="height:100%;overflow: auto;">
        <el-table :data="list" stripe style="width: 100%;">
          <el-table-column prop="date" label="#" type='index' width="30"></el-table-column>
          <el-table-column label="电影" width="180">
            <template slot-scope="scope">
              <span >{{ scope.row.movie.title}}</span>
            </template>
          </el-table-column>
          <el-table-column label="发表时间" width="140">
            <template slot-scope="scope" >
              <i class="el-icon-time"></i>
              <span style="">{{ scope.row.time | timeFormat('YY-MM-DD HH:mm')}}</span>
            </template>
          </el-table-column>
          <el-table-column label="评论标题" width="200">
            <template slot-scope="scope">
              <el-popover trigger="hover" placement="top" width="300">
                <p>评论内容: {{ scope.row.content }}</p>
                <div slot="reference" class="name-wrapper">
                  <el-tag size="medium" effect="dark">{{ scope.row.title}}</el-tag>
                </div>
              </el-popover>
            </template>
          </el-table-column>
          <el-table-column label="不想评论了">
            <template slot-scope="scope">
              <el-popconfirm
                confirmButtonText="不要也罢"
                cancelButtonText="留下见证"
                icon="el-icon-info"
                iconColor="red"
                title="让他消失?"
                @onConfirm="delOne(scope.row)"
              >
                <el-button slot="reference" type="danger" icon="el-icon-delete" circle></el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import Bing from "@/components/bing.vue";
import { getmyping,deleteone } from "@/api";
export default {
  components: {
    Bing,
  },
  data() {
    return {
      list: [],
    };
  },
  methods:{
    delOne(data){
      // console.log(data);
      deleteone(data)
      .then(res=>{
          if(res.type){
            this.list = this.list.filter(item=>item._id!==data._id)
          }
      })
    },
  },
  mounted() {
    getmyping({
      author: sessionStorage.getItem("username"),
    }).then((res) => {
      this.list = res.result;
      console.log(res.result);
    });
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-breadcrumb__inner {
  color: rgb(240, 124, 124) !important;
}
.el-breadcrumb {
  font-size: 30px;
}
.el-row {
  width: 90%;
  height: 540px;
  margin: 0 auto;
  background-color: #fff;
}
::v-deep .cell{
  text-align: center;
}
</style>